<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="include::head"></head>
<body>
<div class="layui-fluid">
    <!--form表单-->
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-block">
                <input type="text" name="roleName" autocomplete="off" class="layui-input" lay-verify="required|roleName" th:value="${role.roleName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色标识</label>
            <div class="layui-input-block">
                <input type="text" name="roleRoute" th:value="${role.roleRoute}" autocomplete="off" class="layui-input" lay-verify="required|roleRoute">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <th:block th:each="value : ${diy['state_type']}">
                        <input th:if="${value.dictionaryRoute == role.isState}" type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                        <input th:if="${value.dictionaryRoute != role.isState}" type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                </th:block>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remarks" th:utext="${role.remarks}" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">权限：</label>
            <div class="layui-input-block">
                <div id="role-tree" >loding... ...</div>
            </div>
        </div>

        <input name="roleId" th:value="${role.roleId}" type="hidden">
        <input id="menuIds" name="menuIds" lay-verify="menuIds" type="hidden">

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div id="alert-tree" style="display: none">
    <div class=""  id="tree">loding... ...</div>
</div>
<div th:include="include::onload"></div>
<script  th:inline="javascript">
    layui.config({
        base: '/js/layer/module/'//模块存放的目录
    }).use(['areal','form','iconPicker','verify'], function(){
        var form = layui.form,
            verify = layui.verify;

        $.tree.initCheckbox("#role-tree",[[${tree}]]);

        verify.verification("#role-tree",[[${role}]]);

        // 监听提交
        form.on('submit(edit)', function(data) {
            $.achieve.post("/admin/system/role/update",data.field,"",true);
            return false;
        });

    });
</script>
</body>
</html>